package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.ComplainSuggest;
import com.ruoyi.system.mapper.ComplainSuggestMapper;
import com.ruoyi.system.service.IComplainSuggestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 投诉建议Service业务层处理
 * 
 * @author ...
 * @date 2022-03-18
 */
@Service
public class ComplainSuggestServiceImpl implements IComplainSuggestService 
{
    @Autowired
    private ComplainSuggestMapper complainSuggestMapper;

    /**
     * 查询投诉建议
     * 
     * @param id 投诉建议主键
     * @return 投诉建议
     */
    @Override
    public ComplainSuggest selectComplainSuggestById(Integer id)
    {
        return complainSuggestMapper.selectComplainSuggestById(id);
    }

    /**
     * 查询投诉建议列表
     * 
     * @param complainSuggest 投诉建议
     * @return 投诉建议
     */
    @Override
    public List<ComplainSuggest> selectComplainSuggestList(ComplainSuggest complainSuggest)
    {
        return complainSuggestMapper.selectComplainSuggestList(complainSuggest);
    }

    /**
     * 新增投诉建议
     * 
     * @param complainSuggest 投诉建议
     * @return 结果
     */
    @Override
    public int insertComplainSuggest(ComplainSuggest complainSuggest)
    {
        complainSuggest.setCreateTime(DateUtils.getNowDate());
        return complainSuggestMapper.insertComplainSuggest(complainSuggest);
    }

    /**
     * 修改投诉建议
     * 
     * @param complainSuggest 投诉建议
     * @return 结果
     */
    @Override
    public int updateComplainSuggest(ComplainSuggest complainSuggest)
    {
        complainSuggest.setUpdateTime(DateUtils.getNowDate());
        return complainSuggestMapper.updateComplainSuggest(complainSuggest);
    }

    /**
     * 批量删除投诉建议
     * 
     * @param ids 需要删除的投诉建议主键
     * @return 结果
     */
    @Override
    public int deleteComplainSuggestByIds(Integer[] ids)
    {
        return complainSuggestMapper.deleteComplainSuggestByIds(ids);
    }

    /**
     * 删除投诉建议信息
     * 
     * @param id 投诉建议主键
     * @return 结果
     */
    @Override
    public int deleteComplainSuggestById(Integer id)
    {
        return complainSuggestMapper.deleteComplainSuggestById(id);
    }

    @Override
    public List<ComplainSuggest> getMy() {
        int userId = SecurityUtils.getUserId().intValue();
        return complainSuggestMapper.getMy(userId);
    }
}
